DISTINCT within aggregates.
От | Stuart Rison |
---|---|
Тема | DISTINCT within aggregates. |
Дата | |
Msg-id | v04003a06b30c53de10b9@[128.40.242.190] обсуждение исходный текст |
Список | pgsql-sql |
Hi, I have PG 6.4 which does not appear to support DISTINCT with aggregates. Here's an example with the following table: key|numero ---+----- 1|one 2|two 3|three 4|one 4|four 2|one (6 rows) brecard10=> select count(numero) from test; count ----- 6 (1 row) brecard10=> select count(numero) from test group by value; count ----- 1 3 1 1 (4 rows) brecard10=> select count(distinct numero) from test group by value; ERROR: parser: Syntax error at or near "distinct" I want to be able to count how many DISTINCT 'numero' entries there are in test (i.e 4). The first statement is a simple count. The second uses a group which does indeed tell us that there are four different 'numero's but does not return a unique count. The last statement is the statement to use (at least according to my SQL handbook - Bowman et al.) but is not supported by PG 6.4. Has anybody found a workaround? cheers, Stuart. +-------------------------+--------------------------------------+ | Stuart Rison | Ludwig Institute for Cancer Research | +-------------------------+ 91 Riding House Street | | Tel. (0171) 878 4041 | London, W1P 8BT, UNITED KINGDOM. | | Fax. (0171) 878 4040 | stuart@ludwig.ucl.ac.uk | +-------------------------+--------------------------------------+
В списке pgsql-sql по дате отправления: